<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head><title>
    个人中心
</title>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="renderer" content="webkit">
    <!--    <meta name="referrer" content="no-referrer">-->
    <script lang="javascript" type="text/javascript" th:src="@{https://libs.baidu.com/jquery/1.11.3/jquery.min.js}"></script>
    <link rel="stylesheet" th:href="@{/css/core.min-20160809.css}">
    <link rel="stylesheet" th:href="@{/css/dushu.min-20160802.css}">
    <link rel="stylesheet" th:href="@{/css/font_1468833227_139596.css}">
    <link rel="stylesheet" th:href="@{/user/css/bootstrap.min.css}">
    <link rel="stylesheet" th:href="@{/user/css/users.css}">

    <script>
        /*判断是否要显示登陆注册*/
        $(function () {
            if ($('.float-right').find("a:eq(0)").text() == '欢迎回来') {
                $(".float-right").find("a:eq(0)").attr("href", "javascript:;");
                $(".float-right").find("a:eq(1)").attr("href", "javascript:;");
            }
        })
    </script>
</head>
<style>
    p{
        font-size: 10px;
    }
    body::-webkit-scrollbar {
        display: none;
    }
</style>
<body style="background: #ededed;">
<!--实现登录注册-->
<div class="layout bg border-bottom">
    <div class="container height-big text-gray">
        <span class="float-right">
            <a th:href="@{/index/toLogin}" th:text="${session.user}==null?'注册':'欢迎回来'" class="text-gray"></a>
            <span class="text-little">|</span>
            <a th:href="@{/index/toLogin}" class="text-gray" th:text="${session.user}==null?'登陆':${session.user.phone}"></a>
        </span>读书好，好读书，读好书！
    </div>
</div>
<div class="container" >
    <div class="row row-info" style="background: #fff;height: 100%">
        <div class="info-top">
            <h2>修改资料</h2>
        </div>
        <div class="info-center">
            <div>
                <div class="col-lg-3">
                    <embed th:src="@{/user/img/info.svg}" th:title="修改头像" style="display:block;width:250px;height:250px; margin-left: -40px;margin-top: 100px;"/>
                </div>
                <div class="col-lg-9">
                    <form th:action="@{/index/doUpdateAccount}" class="form-info">
                        <input type="hidden" class="form-control" name="id" id="id"  th:value="${user.id}">

                        <div class="form-group row ">
                            <label for="phone" class="col-sm-2 col-form-label" >电话号码</label>
                            <div class="col-sm-10">
                                <input type="text" readonly class="form-control" id="phone" name="name" th:value="${user.phone}">
                            </div>
                        </div>

                        <div class="form-group row checked-2">
                            <label for="password" class="col-sm-2 col-form-label">密码</label>
                            <div class="col-sm-10">
                                <input type="text" name="password" class="form-control" id="password" th:value="${user.password}">
                            </div>
                        </div>

                        <div class="form-group row checked-2">
                            <label for="nickname" class="col-sm-2 col-form-label">昵称</label>
                            <div class="col-sm-10">
                                <input type="text" name="nickname" class="form-control" id="nickname" th:value="${user.nickname}==null?'昵称':${user.nickname}">
                            </div>
                        </div>
                        <div class="form-group row checked-2">
                            <label for="sex" class="col-sm-2 col-form-label">sex</label>
                            <div class="col-sm-10">
                                <input type="text" name="sex" class="form-control" placeholder="性别" id="sex" th:value="${user.sex}">
                            </div>
                        </div>
                        <div class="form-group row checked-2">
                            <label for="qq" class="col-sm-2 col-form-label">QQ</label>
                            <div class="col-sm-10">
                                <input type="text" name="qq" class="form-control" id="qq" th:value="${user.qq}">
                            </div>
                        </div>

                        <div style="margin-top: 40px;display: block">
                            <span style="margin-left: 20%;"><a th:href="@{/}">返回首页</a></span>
                            <input type="button" class="btn btn-lg  btn-info" onclick="update()" value="修改">
                            <input class="btn btn-primary btn-lg" type="reset" value="重置">
                            <input class="btn btn-primary btn-lg" type="button"  onclick="exitSession()" value="退出登录">
                        </div>

                    </form>
                </div>
            </div>
        </div>
    </div>
</div>

<div class="layout" id="footer">
    <div class="container padding">
        <div class="text-center">
            <ul class="nav nav-inline">
                <li><a href="1587.html">关于读书</a> </li>
                <li><a href="1588.html">免责声明</a> </li>
                <li><a href="1589.html">读书目录</a> </li>
                <li><a href="1590.html">联系我们</a> </li>
            </ul>
        </div>
        <div class="text-center height-big">Copyright © 读书网 www.dushu.com 2005-2020, All Rights Reserved.</div>
        <div class="text-center height-big"><a href="javascript:;">鄂ICP备15019699号</a> <img th:src="@{/picture/beian.png}" style="vertical-align:middle;margin-left:10px;"> 鄂公网安备 42010302001612号</div>
    </div>
</div>
<script th:src="@{/user/js/jquery-3.2.1.js}"></script>
<script th:src="@{/user/js/bootstrap.min.js}"></script>
<script th:src="@{https://cdnjs.cloudflare.com/ajax/libs/bootbox.js/5.4.0/bootbox.min.js}"></script>
<script>

    $('#password').blur(function () {
        var pwd = $("#password").val();
        var reg = /^[a-zA-Z]\w{5,17}$/;
        if(!reg.test(pwd)){
            bootbox.alert("以字母开头，长度在6~18之间，只能包含字母、数字和下划线");
            return ;
        }
    });

    function update() {
        bootbox.confirm({
            size:"small",
            message:"确定修改吗?",
            buttons:{
                confirm: {
                    label:'确定'
                },
                cancel:{
                    label:'取消'
                }
            },
            callback:function(result){
                if (result){
                    $.post(
                        "/index/doUpdateAccount",
                        {"id":$("#id").val(),"nickName":$("#nickname").val(),"password":$("#password").val(),"phone":$("#phone").val(),'sex':$("#sex").val(),'qq':$("#Fqq").val()},
                        function (data) {
                            if (data.code == 200){
                                bootbox.alert("修改成功！");
                                setTimeout(function () {
                                    window.location.reload();
                                },2000)
                            }else {
                                bootbox.alert("修改失败！")
                            }
                        },"json")}
            }
        })
    }

    function exitSession() {
        $.post("/index/exit");
    }
</script>
<script lang="javascript" type="text/javascript" th:src="@{https://a.dushu.com/js/common.min.js?v=201706}"></script>
</body>
</html>
